#include "DTOFlight.h"
#include "../../utils/Logger.h"

DTOFlight::DTOFlight(): DTO(FLIGHT) {
	this->flightId = -1;
	this->state = -1;
	this->runwayId = -1;
}

DTOFlight::DTOFlight(std::string& aDeserealizar): DTO(FLIGHT) {
	deserializar(aDeserealizar);
}

DTOFlight::DTOFlight(unsigned int flightId,unsigned int  state,int runwayId )
: DTO(FLIGHT), flightId(flightId),state(state),runwayId(runwayId){
}

DTOFlight::~DTOFlight() {
}

int DTOFlight::getRunwayId(){
	return runwayId;
}

unsigned int DTOFlight::getState(){
	return this->state;
}
unsigned int DTOFlight::getFlightId(){
	return flightId;
}

std::string DTOFlight::serializar(){
	std::stringstream retorno;
	retorno << DTO::serializar();
	retorno << UtilString::intToString(flightId);
	retorno << PLANO_SEPARATOR;
	retorno << UtilString::intToString(state);
	retorno << PLANO_SEPARATOR;
	retorno << UtilString::intToString(runwayId);

	return (retorno.str());
}

void DTOFlight::deserializar(std::string& string){

	std::vector<std::string> valores;
	UtilString::splitWithSeparator(&valores,string,PLANO_SEPARATOR);

	flightId = UtilString::stringToInt(valores[1]);
	state = UtilString::stringToInt(valores[2]);
	runwayId = UtilString::stringToInt(valores[3]);
}


std::string DTOFlight::toString(){
	std::stringstream retorno;

	retorno << " Vuelo : " << flightId;
	retorno << " state : " << state;
	retorno << " runwayId : " << runwayId;

	return retorno.str();
}

